package com.xn.app.muying.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.bean.ChanJianMessageBean;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/29.
 */
public class ChanJianDetailAdapter extends BaseAdapter {

    private LayoutInflater inflater;
    private Context context;
    public ArrayList<ChanJianMessageBean> list = new ArrayList<ChanJianMessageBean>();

    public ChanJianDetailAdapter(Context context, ArrayList list) {
        this.context = context;
        this.list = list;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(final int i, View view, ViewGroup viewGroup) {

        ViewHoler_GridView viewHoler_gridView = null;

        if (view == null) {
            viewHoler_gridView = new ViewHoler_GridView();
            view = inflater.inflate(R.layout.item_gridview, null);
            viewHoler_gridView.btn_name = (TextView) view.findViewById(R.id.item_gridview_btn);
            view.setTag(viewHoler_gridView);
        } else {
            viewHoler_gridView = (ViewHoler_GridView) view.getTag();
        }
        viewHoler_gridView.btn_name.setText(list.get(i).getName());
        return view;
    }


    class ViewHoler_GridView {
        TextView btn_name;
    }
}
